/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.gov.ana.entities;

import java.io.Serializable;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.Date;
import java.util.List;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author lucas.nunes
 */
@Entity
@Table(name = "GEOFT_MUNICIPIO")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Municipio.findAll", query = "SELECT m FROM Municipio m"),
    @NamedQuery(name = "Municipio.findByMunCd", query = "SELECT m FROM Municipio m WHERE m.munCd = :munCd"),
    @NamedQuery(name = "Municipio.findByMunCdIbge", query = "SELECT m FROM Municipio m WHERE m.munCdIbge = :munCdIbge"),
    @NamedQuery(name = "Municipio.findByMunNm", query = "SELECT m FROM Municipio m WHERE m.munNm = :munNm"),
    @NamedQuery(name = "Municipio.findByMunSg", query = "SELECT m FROM Municipio m WHERE m.munSg = :munSg"),
    @NamedQuery(name = "Municipio.findByMunArTotalKm2", query = "SELECT m FROM Municipio m WHERE m.munArTotalKm2 = :munArTotalKm2"),
    @NamedQuery(name = "Municipio.findByMunQtPopulacao", query = "SELECT m FROM Municipio m WHERE m.munQtPopulacao = :munQtPopulacao"),
    @NamedQuery(name = "Municipio.findByMunGmPoligono", query = "SELECT m FROM Municipio m WHERE m.munGmPoligono = :munGmPoligono"),
    @NamedQuery(name = "Municipio.findByMunMicCd", query = "SELECT m FROM Municipio m WHERE m.munMicCd = :munMicCd"),
    @NamedQuery(name = "Municipio.findByMunArUrbanaKm2", query = "SELECT m FROM Municipio m WHERE m.munArUrbanaKm2 = :munArUrbanaKm2"),
    @NamedQuery(name = "Municipio.findByMunArRuralKm2", query = "SELECT m FROM Municipio m WHERE m.munArRuralKm2 = :munArRuralKm2"),
    @NamedQuery(name = "Municipio.findByMunDtEmancipacao", query = "SELECT m FROM Municipio m WHERE m.munDtEmancipacao = :munDtEmancipacao"),
    @NamedQuery(name = "Municipio.findByMunAaReferencia", query = "SELECT m FROM Municipio m WHERE m.munAaReferencia = :munAaReferencia"),
    @NamedQuery(name = "Municipio.findByMunNmMunicipioOrigem", query = "SELECT m FROM Municipio m WHERE m.munNmMunicipioOrigem = :munNmMunicipioOrigem"),
    @NamedQuery(name = "Municipio.findByUf", query = "SELECT m FROM Municipio m WHERE m.ufdCd = :ufdCd ORDER BY m.munNm")
})
public class Municipio implements Serializable {

    private static final long serialVersionUID = 1L;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "MUN_CD")
    private BigDecimal munCd;
    @Size(max = 17)
    @Column(name = "MUN_CD_IBGE")
    private String munCdIbge;
    @Size(max = 100)
    @Column(name = "MUN_NM")
    private String munNm;
    @Size(max = 5)
    @Column(name = "MUN_SG")
    private String munSg;
    @Column(name = "MUN_AR_TOTAL_KM2")
    private BigInteger munArTotalKm2;
    @Column(name = "MUN_QT_POPULACAO")
    private Long munQtPopulacao;
    @Size(max = 4000)
    @Column(name = "MUN_GM_POLIGONO")
    private String munGmPoligono;
    @Column(name = "MUN_MIC_CD")
    private BigInteger munMicCd;
    @Column(name = "MUN_AR_URBANA_KM2")
    private BigDecimal munArUrbanaKm2;
    @Column(name = "MUN_AR_RURAL_KM2")
    private BigDecimal munArRuralKm2;
    @Column(name = "MUN_DT_EMANCIPACAO")
    @Temporal(TemporalType.TIMESTAMP)
    private Date munDtEmancipacao;
    @Column(name = "MUN_AA_REFERENCIA")
    private Short munAaReferencia;
    @Size(max = 200)
    @Column(name = "MUN_NM_MUNICIPIO_ORIGEM")
    private String munNmMunicipioOrigem;
    @JoinColumn(name = "UFD_CD", referencedColumnName = "UFD_CD")
    @ManyToOne
    private UnidadeFederacao ufdCd;
    @OneToMany(mappedBy = "uslMunCd")
    private List<UsinaLocalizacao> usinaLocalizacaoList;
    @OneToMany(mappedBy = "orgMunCd")
    private List<Orgao> orgaoList;

    /**
     *
     */
    public Municipio() {
    }

    /**
     *
     * @param munCd
     */
    public Municipio(BigDecimal munCd) {
        this.munCd = munCd;
    }

    /**
     *
     * @return
     */
    public BigDecimal getMunCd() {
        return munCd;
    }

    /**
     *
     * @param munCd
     */
    public void setMunCd(BigDecimal munCd) {
        this.munCd = munCd;
    }

    /**
     *
     * @return
     */
    public String getMunCdIbge() {
        return munCdIbge;
    }

    /**
     *
     * @param munCdIbge
     */
    public void setMunCdIbge(String munCdIbge) {
        this.munCdIbge = munCdIbge;
    }

    /**
     *
     * @return
     */
    public String getMunNm() {
        return munNm;
    }

    /**
     *
     * @param munNm
     */
    public void setMunNm(String munNm) {
        this.munNm = munNm;
    }

    /**
     *
     * @return
     */
    public String getMunSg() {
        return munSg;
    }

    /**
     *
     * @param munSg
     */
    public void setMunSg(String munSg) {
        this.munSg = munSg;
    }

    /**
     *
     * @return
     */
    public BigInteger getMunArTotalKm2() {
        return munArTotalKm2;
    }

    /**
     *
     * @param munArTotalKm2
     */
    public void setMunArTotalKm2(BigInteger munArTotalKm2) {
        this.munArTotalKm2 = munArTotalKm2;
    }

    /**
     *
     * @return
     */
    public Long getMunQtPopulacao() {
        return munQtPopulacao;
    }

    /**
     *
     * @param munQtPopulacao
     */
    public void setMunQtPopulacao(Long munQtPopulacao) {
        this.munQtPopulacao = munQtPopulacao;
    }

    /**
     *
     * @return
     */
    public String getMunGmPoligono() {
        return munGmPoligono;
    }

    /**
     *
     * @param munGmPoligono
     */
    public void setMunGmPoligono(String munGmPoligono) {
        this.munGmPoligono = munGmPoligono;
    }

    /**
     *
     * @return
     */
    public BigInteger getMunMicCd() {
        return munMicCd;
    }

    /**
     *
     * @param munMicCd
     */
    public void setMunMicCd(BigInteger munMicCd) {
        this.munMicCd = munMicCd;
    }

    /**
     *
     * @return
     */
    public BigDecimal getMunArUrbanaKm2() {
        return munArUrbanaKm2;
    }

    /**
     *
     * @param munArUrbanaKm2
     */
    public void setMunArUrbanaKm2(BigDecimal munArUrbanaKm2) {
        this.munArUrbanaKm2 = munArUrbanaKm2;
    }

    /**
     *
     * @return
     */
    public BigDecimal getMunArRuralKm2() {
        return munArRuralKm2;
    }

    /**
     *
     * @param munArRuralKm2
     */
    public void setMunArRuralKm2(BigDecimal munArRuralKm2) {
        this.munArRuralKm2 = munArRuralKm2;
    }

    /**
     *
     * @return
     */
    public Date getMunDtEmancipacao() {
        return munDtEmancipacao;
    }

    /**
     *
     * @param munDtEmancipacao
     */
    public void setMunDtEmancipacao(Date munDtEmancipacao) {
        this.munDtEmancipacao = munDtEmancipacao;
    }

    /**
     *
     * @return
     */
    public Short getMunAaReferencia() {
        return munAaReferencia;
    }

    /**
     *
     * @param munAaReferencia
     */
    public void setMunAaReferencia(Short munAaReferencia) {
        this.munAaReferencia = munAaReferencia;
    }

    /**
     *
     * @return
     */
    public String getMunNmMunicipioOrigem() {
        return munNmMunicipioOrigem;
    }

    /**
     *
     * @param munNmMunicipioOrigem
     */
    public void setMunNmMunicipioOrigem(String munNmMunicipioOrigem) {
        this.munNmMunicipioOrigem = munNmMunicipioOrigem;
    }

    /**
     *
     * @return
     */
    public UnidadeFederacao getUfdCd() {
        return ufdCd;
    }

    /**
     *
     * @param ufdCd
     */
    public void setUfdCd(UnidadeFederacao ufdCd) {
        this.ufdCd = ufdCd;
    }

    /**
     *
     * @return
     */
    @XmlTransient
    public List<UsinaLocalizacao> getUsinaLocalizacaoList() {
        return usinaLocalizacaoList;
    }

    /**
     *
     * @param usinaLocalizacaoList
     */
    public void setUsinaLocalizacaoList(List<UsinaLocalizacao> usinaLocalizacaoList) {
        this.usinaLocalizacaoList = usinaLocalizacaoList;
    }

    /**
     *
     * @return
     */
    @XmlTransient
    public List<Orgao> getOrgaoList() {
        return orgaoList;
    }

    /**
     *
     * @param orgaoList
     */
    public void setOrgaoList(List<Orgao> orgaoList) {
        this.orgaoList = orgaoList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (munCd != null ? munCd.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Municipio)) {
            return false;
        }
        Municipio other = (Municipio) object;
        if ((this.munCd == null && other.munCd != null) || (this.munCd != null && !this.munCd.equals(other.munCd))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return this.munNm;
    }
}
